<template>
  <div class="login-form" v-show="getShow">
    <LoginFormTitle class="enter-x" />
    <div id="up-qrcode" class="enter-x min-w-64 min-h-64">
      <QrCode
        :value="qrCodeUrl"
        class="enter-x flex justify-center xl:justify-start"
        :width="280"
      />
      <Divider class="enter-x">{{ t('sys.login.scanSign') }}</Divider>
      <Button size="large" block class="mt-4 enter-x" @click="handleBackLogin">
        {{ t('sys.login.backSignIn') }}
      </Button>
    </div>
  </div>
</template>
<script lang="ts">
  import { defineComponent, computed, unref } from 'vue';

  import LoginFormTitle from './LoginFormTitle.vue';
  import { Button, Divider } from 'ant-design-vue';
  import { QrCode } from '@/components/Qrcode/index';

  import { useI18n } from '@/locales/useI18n';
  import { useLoginState, LoginStateEnum } from './useLogin';

  const qrCodeUrl = 'https://vvbin.cn/next/login';
  export default defineComponent({
    name: 'QrCodeForm',
    components: {
      Button,
      QrCode,
      Divider,
      LoginFormTitle,
    },
    setup() {
      const { t } = useI18n();
      const { handleBackLogin, getLoginState } = useLoginState();

      const getShow = computed(() => unref(getLoginState) === LoginStateEnum.QR_CODE);

      return {
        t,
        handleBackLogin,
        qrCodeUrl,
        getShow,
      };
    },
  });
</script>
<style scoped>
#up-qrcode{
  background-color: white;
}
.ant-form{
  padding: 20px;
  background-color: white;
}
.ant-form >>> .ant-col {
  width: 100% !important;
}
.enter-x.flex.justify-center{
  text-align: center;
}
.login-form {
  width: 50%;
  min-width: 300px;
  height: 50vh;
  margin: auto;
  margin-top: 5%;
  /* background-color: #fff; */
  font-size: 1.3em;
  background-color: white;
  
}
.login-form h2 {
  font-weight: 900;
  padding-left: 20px;
  padding-top:10px;
  margin: 0em;
}
</style>
